<!doctype html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/_mozilla/bluetooth/bluetooth-helpers.js"></script>
<script>
'use strict';
promise_test(t => {
    window.testRunner.setBluetoothMockDataSet(adapter_type.heart_rate);
    return window.navigator.bluetooth.requestDevice({
        filters: [{services: [generic_access.name], }],
        optionalServices: ['generic_access']
    })
    .then(device => device.gatt.connect())
    .then(gattServer => gattServer.getPrimaryService(generic_access.name))
    .then(service => service.getCharacteristic(device_name.name))
    .then(characteristic => characteristic.getDescriptor(
                                client_characteristic_configuration.name))
    .then(descriptor => {
        return descriptor.readValue()
        .then(() => promise_rejects_dom(t, 'SecurityError', descriptor.writeValue(new Uint8Array(1))));
    });
}, 'Descriptor with exclude-writes fullfills read and rejects write.');
</script>
